<?php

use Illuminate\Database\Seeder;

class AdminUserTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //  创建用户
        $admin = \App\Models\Admin\User::create([
            'name' => '冯炎',
            'email' => 'fengyan@mail.com',
            'password' => bcrypt('123456'),
            'api_token' => str_random(60),
        ]);

        $owner = \App\Models\Admin\User::create([
            'name' => '管理员',
            'email' => 'admin@mail.com',
            'password' => bcrypt('123456'),
            'api_token' => str_random(60),
        ]);

        //  把权限分配给用户
        $developer = \App\Models\Admin\Role::where('name', '=', 'developer')->first();
        $admin->attachRole($developer);

        $administrator = \App\Models\Admin\Role::where('name', '=', 'administrator')->first();
        $owner->attachRole($administrator);


    }
}
